<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .box1 {
        width: 200px;
        height: 200px;
        border: solid 1px black;
        position: relative;
        background: url(../../../../h5_2113/day01/lmages/glnz.jpg) no-repeat
          center/100%;
      }
      .box2 {
        width: 16px;
        height: 16px;
        border: solid 1px blueviolet;
        background: chartreuse;
        position: absolute;
        text-align: center;
        padding: 0;
        right: 0;
      }
      .box2:hover {
        top: 0;
        left: 0;
      }
    </style>
  </head>
  <div class="box1">
    是兄弟就来砍我

    <button class="box2">X</button>
  </div>
  <body>
    <!-- 4.完善流氓广告 关了之后过一段时间还有显示； -->
    <script>
      var box2Ele = document.querySelector(".box2");
      var box1Ele = document.querySelector(".box1");
      box2Ele.onclick = function () {
        box1Ele.style.display = "none";
        box2Ele.style.display = "none";
        // window.location.href = "http://www.baidu.com";
        setTimeout(function () {
          box1Ele.style.display = "block";
          box2Ele.style.display = "block";
        }, 2000);
      };
    </script>
  </body>
</html>
